package com.l2j.test.web.admin.controller.apartment;


import com.l2j.test.common.result.Result;
import com.l2j.test.model.entity.PaymentType;
import com.l2j.test.web.admin.service.PaymentTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "支付方式管理")
@RequestMapping("/admin/payment")
@RestController
@Controller
public class PaymentTypeController {

    @Autowired
//    @Qualifier("PaymentTypeServiceImpl")
    private PaymentTypeService service1;
//    private final PaymentTypeService paymentTypeService; //换构造器方式注入
//    //public PaymentTypeController(@Qualifier("paymentTypeServiceImpl") PaymentTypeService paymentTypeService) {
//    public PaymentTypeController(PaymentTypeService paymentTypeServiceImpl) {
//        this.paymentTypeService = paymentTypeServiceImpl;
//    }
    @Operation(summary = "查询全部支付方式列表")
    @GetMapping("list")
    public Result<List<PaymentType>> listPaymentType() {
        List<PaymentType> list = service1.list();
        return Result.ok(list);
    }

    @Operation(summary = "保存或更新支付方式")
    @PostMapping("saveOrUpdate")
    public Result saveOrUpdatePaymentType(@RequestBody PaymentType paymentType) {
        service1.saveOrUpdate(paymentType);
        return Result.ok();
    }

    @Operation(summary = "根据ID删除支付方式")
    @DeleteMapping("deleteById")
    public Result deletePaymentById(@RequestParam Long id) {
        service1.removeById(id);
        return Result.ok();
    }

}















